
#define _CRT_SECURE_NO_DEPRECATE

#include "platform.h"
#include "utility_log.h"

void logger::appendLineToFile( const char *_file, const char *_line )
	{
	FILE *fpOut;
	fpOut = fopen( _file, "a+" );
	fputs( _line, fpOut );
	fclose( fpOut );
	}

void logger::errorf( const char *_sourceCodeFile, int _sourceCodeLine, const char *_message, ... )
	{
	va_list va;
	va_start( va, _message );
	char buffer[ 65536 ], tbuff[ 65536 ];
	sprintf( tbuff, "\tat \t%s\t%d\n", _sourceCodeFile, _sourceCodeLine );
	vsprintf( buffer, _message, va );
	strcat( buffer, tbuff );
	va_end( va );
	OutputDebugString( buffer );
	appendLineToFile( "errors", buffer );
	appendLineToFile( "log", buffer );
	}

void logger::infof( const char *_sourceCodeFile, int _sourceCodeLine, const char *_message, ... )
	{
	va_list va;
	va_start( va, _message );
	char buffer[ 65536 ], tbuff[ 65536 ];
	sprintf( tbuff, "\tat \t%s\t%d\n", _sourceCodeFile, _sourceCodeLine );
	vsprintf( buffer, _message, va );
	strcat( buffer, tbuff );
	va_end( va );
	OutputDebugString( buffer );
	appendLineToFile( "log", buffer );
	}
